<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include/head::commonHeaderList('自动调课记录列表')">

</head>
<body>
<div id="content" class="col-lg-12 col-sm-12">
    <div class="row">
        <div class="box col-md-12" style="padding: 0;margin-top: 5px;">
            <div class="box-inner">
                <div class="box-header well" data-original-title="">
                    <h2>
                        <i class="glyphicon glyphicon-list"></i> 自动调课记录列表
                    </h2>
                    <div class="box-icon">
                        <a href="javascript:void(0);" id="smaller" class="btn btn-minimize btn-round btn-default"><i class="glyphicon glyphicon-chevron-up"></i></a>
                    </div>
                </div>
                <div class="box-content">
                    <form class="form-inline form-search " role="form" th:action="@{'/class/change/auto/page'}">
                        <div class="form-group" data-chosenWidth="true"  style="margin-bottom: 5px;">
                            <select name="pageSize" class="form-control input-sm" id="pagesize">
                                <option value="15" th:selected="${pageSize==15}">15条/页</option>
                                <option value="25" th:selected="${pageSize==25}">25条/页</option>
                                <option value="50" th:selected="${pageSize==50}">50条/页</option>
                            </select>
                            <select id="state" class="form-control input-sm" name="classState" style="min-width:120px;">
                                <option value="">--状态--</option>
                                <option value="1" th:selected="${classState==1}">待调课</option>
                                <option value="2" th:selected="${classState==2}">调课成功</option>
                                <option value="3" th:selected="${classState==3}">调课失败</option>
                            </select>
                           <!-- <select class="selectpicker" name="listSscId" multiple data-live-search="true" th:title="请选择SSC" data-live-search-placeholder="搜索" data-actions-box="true">
                                <option th:each="item:${listSsc}" th:value="${item.id}" th:selected="${listSscId!=null?(#lists.contains(listSscId,item.id)):false}" th:text="${item.loginName}"></option>
                            </select>-->
                            <input name="classStartDate" id="classStartDate" class="form-control input-sm" maxlength="10" style="min-width:100px;" th:value="${classStartDate}" placeholder="课程开始日期" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'classEndDate\',{d:-1})}'})" autocomplete="off"/>
                            <input name="classEndDate" id="classEndDate" class="form-control input-sm" maxlength="10" style="min-width:100px;" th:value="${classEndDate}" placeholder="课程结束日期" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'classStartDate\',{d:1})}'})" autocomplete="off"/>
                            <input name="startDate" id="startDate" class="form-control input-sm" maxlength="10" style="min-width:100px;" th:value="${startDate}" placeholder="操作开始日期" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\',{d:-1})}'})" autocomplete="off"/>
                            <input name="endDate" id="endDate" class="form-control input-sm" maxlength="10" style="min-width:100px;" th:value="${endDate}" placeholder="操作结束日期" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'startDate\',{d:1})}'})" autocomplete="off"/>
                            <div class="input-group input-group-sm">
                                <input type="search" name="searchKey" id="search" th:value="${searchKey}" class="form-control input-sm" placeholder="查询学员关键字..." style="width:200px;"/>
                                <span class="input-group-btn">
                                    <button class="btn btn-primary" type="submit" > 查 询 </button>
                                </span>
                            </div>&nbsp;
                        </div>
                    </form>
                    <table class="table table-striped table-bordered table-hover footable" data-show-toggle="false">
                        <thead>
                        <tr>
                            <th class="text-center">#</th>
                            <th class="text-center"><input type="checkbox" name="allchecked" value="0" id="allchecked"></th>
                            <th class="text-center">学号</th>
                            <th class="text-center">姓名</th>
                            <th class="text-center">原上课时间</th>
                            <th class="text-center">原上课老师</th>
                            <th class="text-center">操作人</th>
                            <th class="text-center">操作时间</th>
                            <th class="text-center">调课原因</th>
                            <th class="text-center">新上课时间</th>
                            <th class="text-center">新上课老师</th>
                            <th class="text-center">完成调课时间</th>
                            <th class="text-center">状态</th>
                            <th data-breakpoints="all" data-title="原课程id">原课程id</th>
                            <th data-breakpoints="all" data-title="新课程id">新课程id</th>
                            <th class="text-center">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="item,itemStat:${pageInfo.list}">
                            <td class="text-center" th:text="${itemStat.index+1}"></td>
                            <td class="text-center">
                                <input type="checkbox" name="id" th:disabled="${!(item.newLessonId==0 && item.noticeStatus==0 && item.oldLessonId>0)}" th:value="${item.id}">
                            </td>
                            <td class="text-center"><a href="javascript:void(0)" th:text="${item.studentLogin}" th:onclick="|personInfo(${item.studentId})|"></a> </td>
                            <td class="text-center" style="white-space:nowrap;" th:text="${item.cnName}"></td>
                            <td class="text-center" th:text="${#dates.format(item.releaseTime,'yyyy/MM/dd HH:mm')}"></td>
                            <td class="text-center">
                                <a href="javascript:" th:onclick="|showTeacherInfo(${item.teacherId})|" th:text="${item.teacher}"></a>
                            </td>
                            <td class="text-center" th:text="${item.creator}"></td>
                            <td class="text-center" th:text="${#dates.format(item.createTime,'yyyy/MM/dd H:m:s')}"></td>
                            <td class="text-center" th:text="${item.reasonName}"></td>
                            <td class="text-center" th:text="${#dates.format(item.newReleaseTime,'yyyy/MM/dd HH:mm')}"></td>
                            <td class="text-center">
                                <a href="javascript:" th:if="${#strings.isEmpty(item.newTeacher)==false}" th:onclick="|showTeacherInfo(${item.newTeacherId})|" th:text="${item.newTeacher}"></a>
                            </td>
                            <td class="text-center" th:text="${#dates.format(item.changeTime,'yyyy/MM/dd H:m:s')}"></td>
                            <td class="text-center">
                                <label class="label label-default" th:if="${item.newLessonId==0 && item.noticeStatus==0 && item.oldLessonId==0}">原课程已取消</label>
                                <label class="label label-warning" th:if="${item.newLessonId==0 && item.noticeStatus==0 && item.oldLessonId>0}">待调课</label>
                                <label class="label label-success" th:if="${item.newLessonId>0}">调课成功</label>
                                <label class="label label-danger" th:if="${item.newLessonId==0 && item.noticeStatus>0}">调课失败</label>
                            </td>
                            <td th:text="${item.lessonId}"></td>
                            <td th:text="${item.newLessonId}"></td>
                            <td class="text-center">
                                <button th:if="${session.menuMap[363] != null && item.newLessonId==0 && item.noticeStatus==0 && item.oldLessonId>0}" class="btn btn-danger btn-xs" th:onclick="|cancelChangePlan(${item.id})|"><i class="glyphicon icon-white"></i>取消自动调课</button>
                            </td>
                        </tr>
                        </tbody>

                    </table>
                    <div th:include="include/pageinfo::pager"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include/onload_js::onloadJSCustomList(~{::script})">
    <script src="https://hkres.etalk365.com/public/lib/popper/1.15.0/umd/popper.min.js"></script>
    <script src="../../static/js/openPerson.js" th:src="@{'/static/js/openPerson.js'}" ></script>
    <script src="../../static/js/layerTeacherInfo.js" th:src="@{/static/js/layerTeacherInfo.js?v=20210414}"></script>
    <script>
        $(function() {
            $('.footable').footable();
        });

        function cancelChangePlan(id) {
            if (id==null || id==""){
                layer.alert("自动调课id为空");
                return false;
            }
            layer.confirm("您确定将本节课程移除自动调课计划吗？", {
                btn: ['确定','再想想'] //按钮
            }, function(){
                cancelChangePlanSubmit(id);
                return false;
            }, function(){

            });
        }
        function cancelChangePlanSubmit(id) {
            let url="/class/change/auto/cancel/"+id;
            $.post(url,{},function (result){
                if (result.status===1){
                    layer.msg("取消自动调课成功",{icon:1},function (){
                        $("form").submit();
                    });
                }else {
                    layer.msg("取消自动调课失败",{icon:2});
                }
            },"json");
        }
    </script>

</div>
</body>
</html>